#include "../freebsd_list.h"

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/epoll.h>

struct student
{
  int id;
  float weight;
  LIST_ENTRY(student) next;
};

LIST_HEAD(student_head, student);

int main()
{
  struct student_head stu_head;
  LIST_INIT(&stu_head);

  struct student *iter;
  for (int i = 0; i < 5; i++)
  {
    struct student *stu = (struct student *)malloc(sizeof(struct student));
    stu->id = i;
    stu->weight = 100;
    LIST_INSERT_HEAD(&stu_head, stu, next);

    if (i == 3) {iter = stu;}
  }

  LIST_REMOVE(iter, next);
  LIST_FOREACH(iter, &stu_head, next)
  {
    printf("id : %d\n", iter->id);
  }

  printf("\n list access methods  \n");
  iter = LIST_FIRST(&stu_head);
  printf("%d", iter->id);
}
